x86: Make MSI-X work with 64-bit BARs
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 14 May 2008 13:12:53 +0000 (14:12 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 14 May 2008 13:12:53 +0000 (14:12 +0100)
The code for working out the base address of a 64-bit BAR currently
puts the two halves together in the wrong order and leaves the type
bits in the resulting value.   It also treats
PCI_BASE_ADDRESS_MEM_TYPE_64 as a flag rather than an enumeration
value.

Signed-off-by: Neil Turton <nturton@solarflare.com>
xen/arch/x86/msi.c

index bee19a2963b0ae605feb80a773b950e1c88c6344..37d7914841ee3b1b72389a76bc03b5e645752dfc 100644 (file)
@@ -521,17 +521,20 @@ static int msi_capability_init(struct pci_dev *dev, int vector)
 static u64 pci_resource_start(struct pci_dev *dev, u8 bar_index)
 {
     u64 bar_base;
+    u32 reg_val;
     u8 bus = dev->bus;
     u8 slot = PCI_SLOT(dev->devfn);
     u8 func = PCI_FUNC(dev->devfn);
 
-    bar_base = pci_conf_read32(bus, slot, func,
-                               PCI_BASE_ADDRESS_0 + 4 * bar_index);
-    if ( bar_base & PCI_BASE_ADDRESS_MEM_TYPE_64 )
+    reg_val = pci_conf_read32(bus, slot, func,
+                              PCI_BASE_ADDRESS_0 + 4 * bar_index);
+    bar_base = reg_val & PCI_BASE_ADDRESS_MEM_MASK;
+    if ( ( reg_val & PCI_BASE_ADDRESS_MEM_TYPE_MASK ) ==
+         PCI_BASE_ADDRESS_MEM_TYPE_64 )
     {
-        bar_base <<= 32;
-        bar_base += pci_conf_read32(bus, slot, func,
-                               PCI_BASE_ADDRESS_0 + 4 * (bar_index + 1));
+        reg_val = pci_conf_read32(bus, slot, func,
+                                  PCI_BASE_ADDRESS_0 + 4 * (bar_index + 1));
+        bar_base |= ((u64)reg_val) << 32;
     }
 
     return bar_base;